/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package info.sudr.file;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author lei.yang
 */
public class LoadHistory extends HttpServlet {
   
    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet LoadHistory</title>");  
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet LoadHistory at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            */
        } finally { 
            out.close();
        }
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String createby = request.getParameter("upload");
        String createdate = request.getParameter("type");
        String priority = request.getParameter("priority");

        String str = "{\"val\":[{\"nda_id\":18,\"type\":\"IAA\",\"create_date\":\"20120830 08:49:07\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120830 08:49:07\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120830-164910.csv\",\"status\":\"SUBMITTED\",\"priority\":null},{\"nda_id\":17,\"type\":\"IAA\",\"create_date\":\"20120830 08:48:22\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120830 08:48:22\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120830-164826.csv\",\"status\":\"SUBMITTED\",\"priority\":null},{\"nda_id\":16,\"type\":\"IAA\",\"create_date\":\"20120829 08:59:46\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120829 08:59:46\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120829-085945.csv\",\"status\":\"SUBMITTED\",\"priority\":null},{\"nda_id\":15,\"type\":\"IAA\",\"create_date\":\"20120829 05:06:05\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120829 05:06:05\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120829-130609.csv\",\"status\":\"SUBMITTED\",\"priority\":null},{\"nda_id\":14,\"type\":\"IAA\",\"create_date\":\"20120829 05:01:18\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120829 05:01:18\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120829-130121.csv\",\"status\":\"SUBMITTED\",\"priority\":3},{\"nda_id\":13,\"type\":\"IAA\",\"create_date\":\"20120828 10:32:23\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120828 10:32:23\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120828-183230.csv\",\"status\":\"SUBMITTED\",\"priority\":3},{\"nda_id\":12,\"type\":\"IAA\",\"create_date\":\"20120828 10:27:30\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120828 10:27:30\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120828-182737.csv\",\"status\":\"SUBMITTED\",\"priority\":3},{\"nda_id\":11,\"type\":\"IAA\",\"create_date\":\"20120828 10:18:56\",\"create_by\":\"GSI_APP\",\"modify_date\":\"20120828 10:18:56\",\"modify_by\":\"GSI_APP\",\"file_name\":\"GSI_APP-20120828-181902.csv\",\"status\":\"SUBMITTED\",\"priority\":3}],\"flag\":0}";        
        PrintWriter writer = response.getWriter();
        response.setContentType("application/json");
        writer.write(str);
        writer.close();
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
